package car.aistar.controller;

import car.aistar.dto.Result;
import car.aistar.entity.CarStyle;
import car.aistar.service.CarStyleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName cascadeController
 * @Description TODO
 * @Author laoxu
 * @Date 2020/10/21 1:39
 * Version 1.0
 **/
@RestController
@RequestMapping("/cascade")
public class cascadeController {

    @Autowired
    private CarStyleService carStyleService;

    @GetMapping("/{stId}")
    public Result code(@PathVariable("stId") Long stId){
        //品牌id为stId=3
        //查询出此品牌对应的所属车系
        CarStyle carStyle = new CarStyle();
        carStyle.setBrId(stId);
        List<CarStyle> carStyleList = carStyleService.queryAll(carStyle);
        if (null == carStyleList){
            return new Result("500","查询失败");
        }else {
            return new Result("200","验证码发送成功",carStyleList);
        }
    }
}
